/*!
    \file    change log.txt
    \brief   change log for GD32W515P_EVAL demo

    \version 2026-04-15, V2.0.0, demo for gd32w51x_f5hc
*/

/*
    Copyright (c) 2026, GigaDevice Semiconductor Inc.

    Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

    1. Redistributions of source code must retain the above copyright notice, this
       list of conditions and the following disclaimer.
    2. Redistributions in binary form must reproduce the above copyright notice,
       this list of conditions and the following disclaimer in the documentation
       and/or other materials provided with the distribution.
    3. Neither the name of the copyright holder nor the names of its contributors
       may be used to endorse or promote products derived from this software without
       specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/

******************* V2.0.0 2026-04-15 ************************************************************************************
______________________Common___________________________________________________________________________________________
merge GD32W51x series with GD32F5HC series
__________________________________________________________________________________________________________________________

******************* V1.4.0 2025-02-19 ************************************************************************************
______________________Trustzone___________________________________________________________________________________________

Fix file:
../GD32W515P_EVAL_Demo_Suites/Projects/23_Trustzone/Secure_Code/partition_gd32w51x.h

fix reason:
Resolve OSS compliance issues and add ARM version description.

V1.3.0:
/*!
    \file    partition_gd32w51x.h
    \brief   partition_gd32w51x head file

    \version 2024-08-02, V1.3.0, demo for GD32W51x
*/

/*
    Copyright (c) 2024, GigaDevice Semiconductor Inc.

    Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met:

    1. Redistributions of source code must retain the above copyright notice, this 
       list of conditions and the following disclaimer.
    2. Redistributions in binary form must reproduce the above copyright notice, 
       this list of conditions and the following disclaimer in the documentation 
       and/or other materials provided with the distribution.
    3. Neither the name of the copyright holder nor the names of its contributors 
       may be used to endorse or promote products derived from this software without 
       specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
OF SUCH DAMAGE.
*/

V1.4.0:
/*!
    \file    partition_gd32w51x.h
    \brief   partition_gd32w51x head file

    \version 2025-02-19, V1.4.0, demo for GD32W51x
*/

/*
 * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
 * Copyright (c) 2025, GigaDevice Semiconductor Inc.
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the License); you may
 * not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
____________________________________________________________________________________________________________________

******************* V1.3.0 2024-08-02 ************************************************************************************
______________________Common______________________________________________________________________________________________
Fix file:
gd32w51x_it.c
fix reason:
add FPU_IRQHandler function
V1.2.0:
none
V1.3.0:
/*!
    \brief      this function handles FPU exception
    \param[in]  none
    \param[out] none
    \retval     none
*/
void FPU_IRQHandler(void)
{
    /* if FPU exception occurs, go to infinite loop */
    while(1) {
    }
}

Fix file:
gd32w51x_it.h
fix reason:
add the definition of FPU_IRQHandler function
V1.2.0:
none
V1.3.0:
/* this function handles FPU exception */
void FPU_IRQHandler(void);

Fix file:
keil and iar project of 12_TRNG_Get_Random\13_CAU\14_HAU\18_RTC_Calendar\19_TSI
fix reason:
add gd32w51x_it.c to projects that do not have an  gd32w51x_it.c file before
V1.2.0:
none
V1.3.0:
gd32w51x_it.c

Fix file:
all files containing the printf retarget function
fix reason:
Modify the printf retarget function, add the eclipse gcc environment usage
V1.2.0:
/* retarget the C library printf function to the USART */
int fputc(int ch, FILE *f)
{
    usart_data_transmit(EVAL_COM0, (uint8_t)ch);
    while(RESET == usart_flag_get(EVAL_COM0, USART_FLAG_TBE));

    return ch;
}
V1.3.0:
#ifdef GD_ECLIPSE_GCC
/* retarget the C library printf function to the USART, in Eclipse GCC environment */
int __io_putchar(int ch)
{
    usart_data_transmit(EVAL_COM0, (uint8_t) ch );
    while(RESET == usart_flag_get(EVAL_COM0, USART_FLAG_TBE));
    return ch;
}
#else
/* retarget the C library printf function to the USART */
int fputc(int ch, FILE *f)
{
    usart_data_transmit(EVAL_COM0, (uint8_t)ch);
    while(RESET == usart_flag_get(EVAL_COM0, USART_FLAG_TBE));

    return ch;
}
#endif /* GD_ECLIPSE_GCC */
__________________________________________________________________________________________________________________________

______________________CAU_________________________________________________________________________________________________

Fix file:
../GD32W515P_EVAL_Demo_Suites/Projects/13_CAU/main.h
fix reason:
modify the definitions of keys, plaintext and addmessage
V1.2.0:
/* key with 128 bits */
uint8_t aes_key_128[16] = {0x2b,0x7e,0x15,0x16,0x28,0xae,0xd2,0xa6,
                           0xab,0xf7,0x15,0x88,0x09,0xcf,0x4f,0x3c};

/* key with 192 bits */
uint8_t aes_key_192[24] = {0x8e,0x73,0xb0,0xf7,0xda,0x0e,0x64,0x52,
                           0xc8,0x10,0xf3,0x2b,0x80,0x90,0x79,0xe5,
                           0x62,0xf8,0xea,0xd2,0x52,0x2c,0x6b,0x7b};

/* key with 256 bits */
uint8_t aes_key_256[32] = {0x60,0x3d,0xeb,0x10,0x15,0xca,0x71,0xbe,
                           0x2b,0x73,0xae,0xf0,0x85,0x7d,0x77,0x81,
                           0x1f,0x35,0x2c,0x07,0x3b,0x61,0x08,0xd7,
                           0x2d,0x98,0x10,0xa3,0x09,0x14,0xdf,0xf4};

/* key selection */                          
uint8_t *key_select[3] = {aes_key_128, aes_key_192, aes_key_256};
/* key size selection */
uint16_t keysize[3] = {128, 192, 256};

/* key with 64 bits for DES */
uint8_t des_key[8] = {0x2b,0x7e,0x15,0x16,0x28,0xae,0xd2,0xa6}; 

/* key with 192 bits for TDES */
uint8_t tdes_key[24] = {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
                        0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10,
                        0x89,0xAB,0xCD,0xEF,0x01,0x23,0x45,0x67};
/* vectors with 128 bits */
uint8_t vectors[16] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
                       0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};

/* vectors for CCM mode */
uint8_t ccm_vectors[CCM_IV_SIZE] = {0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17};

/* message to be encrypted */
uint8_t plaintext[TEXT_SIZE] = 
                        {0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,
                         0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a,
                         0xae,0x2d,0x8a,0x57,0x1e,0x03,0xac,0x9c,
                         0x9e,0xb7,0x6f,0xac,0x45,0xaf,0x8e,0x51,
                         0x30,0xc8,0x1c,0x46,0xa3,0x5c,0xe4,0x11,
                         0xe5,0xfb,0xc1,0x19,0x1a,0x0a,0x52,0xef,
                         0xf6,0x9f,0x24,0x45,0xdf,0x4f,0x9b,0x17,
                         0xad,0x2b,0x41,0x7b,0xe6,0x6c,0x37,0x10};

/* AAD message for GCM and CCM mode */
uint8_t aadmessage[AAD_SIZE] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
                                0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
V1.3.0:
/* key with 128 bits */
uint8_t aes_key_128[16] = {0x2b,0x7e,0x15,0x16,0x28,0xae,0xd2,0xa6,
                           0xab,0xf7,0x15,0x88,0x09,0xcf,0x4f,0x3c};

/* key with 192 bits */
uint8_t aes_key_192[24] = {0x8e,0x73,0xb0,0xf7,0xda,0x0e,0x64,0x52,
                           0xc8,0x10,0xf3,0x2b,0x80,0x90,0x79,0xe5,
                           0x62,0xf8,0xea,0xd2,0x52,0x2c,0x6b,0x7b};

/* key with 256 bits */
uint8_t aes_key_256[32] = {0x60,0x3d,0xeb,0x10,0x15,0xca,0x71,0xbe,
                           0x2b,0x73,0xae,0xf0,0x85,0x7d,0x77,0x81,
                           0x1f,0x35,0x2c,0x07,0x3b,0x61,0x08,0xd7,
                           0x2d,0x98,0x10,0xa3,0x09,0x14,0xdf,0xf4};

/* key selection */                          
uint8_t *key_select[3] = {aes_key_128, aes_key_192, aes_key_256};
/* key size selection */
uint16_t keysize[3] = {128, 192, 256};

/* key with 64 bits for DES */
uint8_t des_key[8] = {0x2b,0x7e,0x15,0x16,0x28,0xae,0xd2,0xa6}; 

/* key with 192 bits for TDES */
uint8_t tdes_key[24] = {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
                        0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10,
                        0x89,0xAB,0xCD,0xEF,0x01,0x23,0x45,0x67};
/* vectors with 128 bits */
uint8_t vectors[16] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
                       0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};

/* vectors for CCM mode */
uint8_t ccm_vectors[CCM_IV_SIZE] = {0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17};

/* message to be encrypted */
uint8_t plaintext[TEXT_SIZE] = 
                        {0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,
                         0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a,
                         0xae,0x2d,0x8a,0x57,0x1e,0x03,0xac,0x9c,
                         0x9e,0xb7,0x6f,0xac,0x45,0xaf,0x8e,0x51,
                         0x30,0xc8,0x1c,0x46,0xa3,0x5c,0xe4,0x11,
                         0xe5,0xfb,0xc1,0x19,0x1a,0x0a,0x52,0xef,
                         0xf6,0x9f,0x24,0x45,0xdf,0x4f,0x9b,0x17,
                         0xad,0x2b,0x41,0x7b,0xe6,0x6c,0x37,0x10};

/* AAD message for GCM and CCM mode */
uint8_t aadmessage[AAD_SIZE] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
                                0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};

Fix file:
../GD32W515P_EVAL_Demo_Suites/Projects/13_CAU/main.c
fix reason:
code improvement
V1.2.0:
none
V1.3.0:
add cau_deinit() function before cau_struct_para_init(&text) function in xxx_xxx_demo function.
__________________________________________________________________________________________________________________________
______________________Module USB__________________________________________________________________________________________
Fix file:
../GD32W515P_EVAL_Demo_Suites/Projects/22_USBFS/USB_Host/MSC_Host/src/usbh_usr.c
fix reason: 
remove unused headers from the header include
V1.2.0:
#include <string.h>
#include "usbh_usr.h"
#include "drv_usb_hw.h"
#include "ff.h"
#include "usbh_msc_core.h"
#include "usbh_msc_scsi.h"
#include "usbh_msc_bbb.h"
V1.3.0:
#include "usbh_usr.h"
#include "drv_usb_hw.h"
#include "usbh_msc_core.h"
#include "ff.h"
#include <string.h>

Fix file:
../GD32W515P_EVAL_Demo_Suites/Projects/22_USBFS/USB_Host/MSC_Host/src/usbh_usr.c
fix reason: 
modify local variable to global variable
V1.2.0:
int usbh_usr_msc_application(void)
{
    FRESULT res;
    msc_lun info;
    uint8_t WriteTextBuff[] = "GD32 Connectivity line Host Demo application using FAT_FS   ";
    uint16_t bytesWritten, bytesToWrite;
...
V1.3.0:
char ReadTextBuff[100];
char WriteTextBuff[] = "GD32 USB Host Demo application using FAT_FS   ";
uint16_t bytesWritten, bytesToWrite, bytesRead;


Fix file:
../GD32W515P_EVAL_Demo_Suites/Projects/22_USBFS/USB_Host/MSC_Host/src/usbh_usr.c
fix reason: 
add the log display
add the readback verification logic for the written file, if the read and write are consistent, print the corresponding log
V1.2.0:
        case USBH_USR_FS_WRITEFILE:
            usb_mdelay(100U);
            LCD_UsrLog(">>> Press KEY_TAMPER_WAKEUP to write file\r\n");

            /*key b3 in polling*/
            while ((usbh_core.host.connect_status) && \
                    (SET == gd_eval_key_state_get (KEY_TAMPER_WAKEUP))) {
                toggle_leds();
            }

            LCD_UsrLog("> Writing File to disk flash ...\r\n");

            /* register work area for logical drives */
            f_mount(&fatfs, "0:/", 1U);

            if (FR_OK == f_open(&file, "0:GD32.TXT", (uint8_t)(FA_CREATE_ALWAYS | FA_WRITE))) {
                /* write buffer to file */
                bytesToWrite = sizeof(WriteTextBuff); 
                res = f_write (&file, WriteTextBuff, (uint32_t)bytesToWrite, (void *)&bytesWritten);
                /* EOF or error */
                if ((0U == bytesWritten) || (FR_OK != res)) {
                    LCD_ErrLog("> GD32.TXT CANNOT be writen.\r\n");
                } else {
                    LCD_UsrLog("> GD32.TXT created in the disk.\r\n");
                }

                /* close file and filesystem */
                f_close(&file);
                f_mount(NULL, "0:/", 1U); 
            } else {
                LCD_UsrLog("> GD32.TXT created in the disk.\r\n");
            }

            usbh_usr_application_state = USBH_USR_FS_DEMOEND;
            LCD_UsrLog("> The MSC host demo is end.\r\n");
            break;
V1.3.0:
        case USBH_USR_FS_WRITEFILE:
            usb_mdelay(100U);
            LCD_UsrLog(">>> Press Tamper/Wakeup Key to write file\r\n");

            /*key TAMPER_WAKEUP in polling*/
            while ((usbh_core.host.connect_status) && \
                    (SET == gd_eval_key_state_get (KEY_TAMPER_WAKEUP))) {
                toggle_leds();
            }

            LCD_UsrLog("> Writing File to disk flash ...\r\n");

            /* register work area for logical drives */
            f_mount(&fatfs, "0:/", 1U);

            if(FR_OK == f_open(&file, "0:GD32.TXT", (uint8_t)(FA_CREATE_ALWAYS | FA_WRITE))) {
                LCD_UsrLog("> GD32.TXT be opened for write.\r\n");
                /* write buffer to file */
                bytesToWrite = strlen(WriteTextBuff);
                res = f_write (&file, WriteTextBuff, bytesToWrite, (void *)&bytesWritten);
                f_sync(&file);
                /* EOF or error */
                if((0U == bytesWritten) || (FR_OK != res)) {
                    LCD_ErrLog("> GD32.TXT CANNOT be writen.\r\n");
                } else {
                        LCD_UsrLog("> GD32.TXT created in the disk.\r\n");
                        if(FR_OK == f_open(&file, "0:GD32.TXT", FA_READ)) {
                        res = f_read(&file, ReadTextBuff, sizeof(ReadTextBuff), (void *)&bytesRead);
                        /* EOF or error */
                        if((bytesRead == 0) || (res != FR_OK)) {
                            LCD_ErrLog("> GD32.TXT CANNOT be read.\r\n");
                        } else {
                            /* compare file content */
                           if((bytesRead == bytesWritten) && (0 == strncmp(ReadTextBuff, WriteTextBuff, bytesRead))) {
                                LCD_UsrLog("> File content compare: SUCCESS.\r\n");
                            } else {
                                LCD_ErrLog("> File content compare: ERROR.\r\n");
                            }
                        }
                    } else {
                        LCD_ErrLog("> GD32.TXT CANNOT be opened for read.\r\n");
                    }
                  
                }

                /* close file and filesystem */
                f_close(&file);
            } else {
                LCD_ErrLog("> GD32.TXT CANNOT be opened.\r\n");
            }

            f_mount(NULL, "0:/", 1U); 

            usbh_usr_application_state = USBH_USR_FS_DEMOEND;
            LCD_UsrLog("> The MSC host demo is end.\r\n");
            break;

Fix file:
../GD32W515P_EVAL_Demo_Suites/Projects/22_USBFS/USB_Host/MSC_Host/fat_fs/inc/ff_gen_drv.h
../GD32W515P_EVAL_Demo_Suites/Projects/22_USBFS/USB_Host/MSC_Host/fat_fs/src/diskio.c
../GD32W515P_EVAL_Demo_Suites/Projects/22_USBFS/USB_Host/MSC_Host/fat_fs/src/ff_gen_drv.c
fix reason:
code improvement, resolve static test error
V1.2.0:
ff_gen_drv.h
diskio.c
ff_gen_drv.c
V1.3.0:
none
__________________________________________________________________________________________________________________________
